package leetcode_1000;

import helpclass.TreeNode;

public class UnivaluedBinaryTree_965 {
	public boolean isUnivalTree(TreeNode root) {
	   boolean res = true;
       if(root.left != null) {
    	   if(root.val != root.left.val) return false;
    	   res = isUnivalTree(root.left);
    	   if(!res) return false;
       }
       if(root.right != null) {
    	   if(root.val != root.right.val) return false;
    	   res = isUnivalTree(root.right);
    	   if(!res) return false;
       }
       return true;
    }
}
